package com.project.util;

import java.util.Map;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.config.entities.ResultConfig;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import com.opensymphony.xwork2.interceptor.PreResultListener;

public class DownLoadInterceptor extends AbstractInterceptor {
	public String intercept(ActionInvocation invocation) throws Exception{
		invocation.addPreResultListener(new PreResultListener()
		{
			public void beforeResult(ActionInvocation invocation,String resultCode){
				Map<String ,ResultConfig>resultMap = invocation.getProxy().getConfig().getResults();
				ResultConfig finalResultConfig = (ResultConfig)resultMap.get(resultCode);
				
//				finalResultConfig.addParam("contentType" , "application/zip");
//				finalResultConfig.addParam("contentDisposition" , "attachmert;filename=\"abc.zip\"");
				ResultConfig.Builder test = new ResultConfig.Builder(finalResultConfig);
				test.addParam("contentType" , "application/zip");
				test.addParam("contentDisposition" , "attachmert;filename=\"abc.zip\"");
				
			}
		});
		return invocation.invoke();
	}

}
